package io.github.luons.mediator.generator.model;

import io.github.luons.mediator.generator.entity.ParamConfig;
import io.github.luons.mediator.generator.entity.YmlConstant;

import java.util.LinkedHashMap;

/**
 * ComonYml
 *
 * @author : luons
 */
public class CommonYml {

    public static LinkedHashMap<String, Object> ymlError() {
        LinkedHashMap<String, Object> data = new LinkedHashMap<>();

        data.put("swagger", YmlConstant.SWAGGER_VERSION);
        LinkedHashMap<String, Object> def = new LinkedHashMap<>();
        data.put("definitions", def);

        LinkedHashMap<String, Object> err = new LinkedHashMap<>();
        def.put("ErrorInfo", err);
        err.put("x-openapi-module", ParamConfig.MODULE);
        err.put("title", "ErrorInfo");

        LinkedHashMap<String, Object> pro = new LinkedHashMap<>();
        err.put("properties", pro);
        LinkedHashMap<String, Object> code = new LinkedHashMap<>();
        pro.put("code", code);
        code.put("type", "integer");
        code.put("description", "错误码，默认正确为0");

        LinkedHashMap<String, Object> message = new LinkedHashMap<>();
        pro.put("message", message);
        message.put("type", "string");
        message.put("description", "错误信息，默认为空");

        LinkedHashMap<String, Object> status = new LinkedHashMap<>();
        pro.put("status", status);
        status.put("type", "string");
        status.put("description", "错误状态信息，默认为空");

        return data;
    }

    public static LinkedHashMap<String, Object> ymlSummary() {
        LinkedHashMap<String, Object> summary = new LinkedHashMap<>();

        summary.put("swagger", YmlConstant.SWAGGER_VERSION);

        LinkedHashMap<String, Object> info = new LinkedHashMap<>();
        info.put("version", ParamConfig.VERSION);
        info.put("title", "openapi API");
        info.put("description", "");
        summary.put("info", info);
        summary.put("host", ParamConfig.HOST);
        summary.put("x-openapi-version", ParamConfig.VERSION);
        summary.put("x-openapi-revision", "2.0.1");

        return summary;
    }

}
